package com.lww.feature.test.sort;

import org.junit.Test;

import java.math.BigDecimal;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
 * User: yian
 * Date: 2017/5/12
 */
public class test {
    @Test
    public void sort() {
        List<com.lww.feature.test.stream.Foo> list = Arrays.asList(
                new com.lww.feature.test.stream.Foo(1, "P1", new BigDecimal(300), new BigDecimal(400)),
                new com.lww.feature.test.stream.Foo(2, "P2", new BigDecimal(600), new BigDecimal(400)),
                new com.lww.feature.test.stream.Foo(3, "P3", new BigDecimal(30), new BigDecimal(20)),
                new com.lww.feature.test.stream.Foo(3, "P3", new BigDecimal(70), new BigDecimal(20)),
                new com.lww.feature.test.stream.Foo(1, "P1", new BigDecimal(360), new BigDecimal(40)),
                new com.lww.feature.test.stream.Foo(4, "P4", new BigDecimal(320), new BigDecimal(200)),
                new com.lww.feature.test.stream.Foo(4, "P4", new BigDecimal(500), new BigDecimal(900))
        );
        Collections.sort(list,(p1, p2)->p2.getId().compareTo(p1.getId()));
        list.stream().forEach(p-> System.out.println(p));
        Collections.sort(list,(p1, p2)->p1.getId().compareTo(p2.getId()));
        System.out.println("---------------------");
        list.stream().forEach(p-> System.out.println(p));



    }
}
